﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manage_NoReplyQuestion : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string qid = Request.Params["qid"];
            QuestionID.Value = qid;

            try
            {
                CmsDataContext db = new CmsDataContext();
                Question question = (from aQ in db.Question
                                     where aQ.ID == qid
                                     select aQ).First();

                QuestionTitle.Text = question.Title;
                QuestionMemo.Text = question.Memo;
                Description.Text = question.Description;
            }
            catch
            {
            }
        }
    }
    protected void Save_Click(object sender, EventArgs e)
    {
        CmsDataContext db = new CmsDataContext();

        try
        {
            string qid = QuestionID.Value.Trim();

            Question question = (from aQ in db.Question
                                 where aQ.ID == qid
                                 select aQ).First();

            question.Description = Description.Text.Trim();
            db.SubmitChanges();

            MessageBox.Message = "数据保存成功。";
            MessageBox.Location = "./NoReplyQuestion.aspx?qid=" + question.ID;
        }
        catch (Exception ee)
        {
            MessageBox.Message = "保存数据时发生错误：" + ee.Message;
        }
    }
}